<template>
	<div style="margin: 30px;">
		<el-form :inline="true" :model="formInline" class="demo-form-inline">
		  <el-form-item label="来源">
		    <el-select v-model="formInline.platformCode" placeholder="全部">
		      <el-option v-for="item in option1" :label="item.platformCode" :value="item.platformCode" :key='item.plateformCode'></el-option>
		    </el-select>
		  </el-form-item>
		    <el-form-item label="身份证号">
		    <el-input v-model="formInline.userKey" ></el-input>
		  </el-form-item>
		   <el-form-item label="姓名">
		    <el-input v-model="formInline.username" ></el-input>
		  </el-form-item>
		  <el-form-item style='float: right;'>
		    <el-button type="primary" @click="getTrain" :disabled='flag'>搜索</el-button>
		    <el-button type="primary" @click="getTrain">全部</el-button>
		  </el-form-item>
		</el-form>
		<el-table
	    :data="tableData3"
	    height="500"
	    v-loading='loadingFlag'
	    border
	    style="width: 100%">
	    <el-table-column type='index'
	      label="序号"
	      :index="indexMethod"
	    align='center'
	      width="80">
	    </el-table-column>
	    <el-table-column
	      prop="userKey"
	      align='center'
	      label="用户账号"
	      width="180">
	    </el-table-column>
	     <el-table-column
	      prop="username"
	      align='center'
	      label="用户姓名 ">
	    </el-table-column>
	     <el-table-column
	      prop="userKey"
	      align='center'
	      label="身份标识">
	    </el-table-column>
	     <el-table-column
	      prop="platformName"
	      align='center'
	      label="来源">
	    </el-table-column>
	  </el-table>
	  <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-size='20' layout="total,sizes,prev,pager,next,jumper" :total="total"></el-pagination>
	  
	</div>	
</template>
<script>
	import {mapState} from 'vuex'
	import MD5 from 'md5'
	export default {
		
    data() {
      return {
      	 formInline: {
          resource: '',
          platformCode:'',
          userKey:'',
          username:''
          
        },
        option1:[
          	{'platformCode':"20180830"}
          ],
        currentPage:1,
      	total:0,
      	limit:20,
      	loadingFlag:false,
      	flag:false,
         tableData3: [],
        pickerOptions2: {
          shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }]
        },
        time: '',
      };
    },
    computed:{
    	...mapState({
    		detailMessage:'detailMessage'
    	})
    },
    methods: {
    	indexMethod(index){
    		return this.limit*(this.currentPage-1)+index+1
    	},
     handleSizeChange(val){
    		this.limit = val
    		this.getRecord()
    	},
    	handleCurrentChange(val){
    		this.currentPage = val
    		this.getRecord()
    	},
      getTrain(){
      	let that = this
      	this.flag=true
      	this.loadingFlag=true
      	let timestamp = Date.parse(new Date())
      	var arr =[]
      	arr.push(this.formInline.platformCode)
      	let param = {
      		        "platformCode":arr,
      		        "userKey":this.formInline.userKey,
					//"companyCode":"1535616441742",
					"companyCode":this.detailMessage.code,
					'pageSize':this.limit,
					'pageNum':this.currentPage,
					'userName':this.formInline.username
				}
      	console.log(param)
        Object.keys(param).forEach(function(key){
        	if(param[key]=='' || (!param[key]) || (param[key].length=='0')){
        		delete param[key]
        	}
        })
        
        let reqUrl = localStorage.getItem('ApiUrl')+'/idc/company/studentInfo'   
        
        this.$ajax.post(reqUrl,param,{headers:{
						'Content-Type':'application/json',
						'platformCode':'20180830',
						'authorization':MD5('1idc89757'),
						'timestamp':'1'
						
					}
        })
        .then(function(res){
					that.loadingFlag=false
					that.flag=false
					let obj = res.data
					if(obj.code==200){
						that.tableData3=obj.data.list
						that.total = obj.data.total
					}else{
						that.$message({
							message:obj.message,
							duration:5000
						})
					}
        })
        .catch((err)=>{
        	console.log(err)
        })
      }
    },
    mounted(){
    	this.getTrain()
    }
  };
</script>
<style type="text/css">
	
</style>